import BaseCell from '../BaseCell';
import { Input } from 'beeshell';
import BaseItem from '@/components/BaseItem';
import { StyleSheet, Text } from 'react-native';
// import { Tip } from 'beeshell';
export default {
  isJiess: true,
  name: 'BaseInput',
  setup({
    label,
    labelWidth = 72,
    labelAlign = 'left',
    childs,
    ...attrs
  }) {
    const styles = StyleSheet.create({ input: { paddingLeft: 6, height: 36 } });
    const aligns = { left: 'flex-start', center: 'center', right: 'flex-end' };
    const { $val, $ref } = this.jiess;
    const inputValue = $ref(null);
    const initParam = ({ label = '', ...other }) => {
      return {
        is: Input,
        ref: (c) => {
          // console.log(c);
        },
        style: styles.input,
        placeholder: '请输入' + label,
        value: $val(inputValue, 'value'),
        onChange: (e) => { inputValue.value = e },
        ...other
      }
    };

    const content = initParam({ label });
    const result = { is: BaseItem, content, ...attrs };
    if (label) {
      result.label = label;
      result.leftStyle = {
        paddingLeft: 4,
        width: labelWidth,
        alignItems: aligns[labelAlign]
      }
    }
    return this.add(this.render(result));
  },
};
